package ar.edu.uba.fi.jmit.aspecter.testUtils;

import javassist.expr.Expr;
import ar.edu.uba.fi.jmit.aspecter.core.ConstructorDefinition;
import ar.edu.uba.fi.jmit.aspecter.core.DefinitionFactory;
import ar.edu.uba.fi.jmit.aspecter.core.interceptor.ConstructorAccessInterceptor;

public class ExceptionBeforeConstructorInterceptor extends ConstructorAccessInterceptor {

	public ExceptionBeforeConstructorInterceptor(String className) throws ClassNotFoundException {
		super(DefinitionFactory.createConstructor(className));
	}
	
	public ExceptionBeforeConstructorInterceptor(ConstructorDefinition definition) throws ClassNotFoundException {
		super(definition);
	}

	@Override
	public boolean mustAspect(Expr expression) {
		return true;
	}

	@Override
	protected String aspectStatementBefore() {
		return " throw new RuntimeException(\"intercepted!\");";
	}
	
	@Override
	protected String aspectStatementAfter() {
		return "";
	}
}
